package com.david.appletree

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.util.AttributeSet
import android.view.View

class RoundLineView: View {

    var mPaint = Paint()
    var indicatorWidth = 0
    private var indicatorRadius = 0
    private var indicatorSpace = 0

    private var containerWidth = 120f

    constructor(
        context: Context?
    ): super(context)



    constructor(
        context: Context?,
        attrs: AttributeSet?
    ): super(context, attrs)

    constructor(
        context: Context?,
        attrs: AttributeSet?,
        defStyleAttr: Int
    ): super(context, attrs, defStyleAttr) {
        mPaint.strokeCap = Paint.Cap.ROUND
        mPaint.strokeWidth = 5f
    }

//    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
//        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
//        val count = config.indicatorSize
//        if (count <= 1) {
//            return
//        }
//        context?.let {
//            val width = (count - 1) * indicatorSpace + indicatorWidth + indicatorWidth * (count - 1)
//            setMeasuredDimension(width, indicatorWidth)
//        }
//
//    }

//    override fun onPageChanged(count: Int, currentPosition: Int) {
//        super.onPageChanged(count, currentPosition)
////        if (count == 2) {
////            indicatorWidth = 60.dp
////        } else if (count == 3) {
////            indicatorWidth = 40.dp
////        }
////
////    }
////
////    override fun onDraw(canvas: Canvas) {
////        super.onDraw(canvas)
////        if (config.indicatorSize <= 1) {
////            return
////        }
//////        val count = config.indicatorSize
//////        var left = 0f
////
////        mPaint.color = Color.parseColor("#868686")
////        canvas.drawRoundRect(RectF(0F, 10F, width.toFloat(), 15.dp.toFloat()), 10F, 10F, mPaint)
////
////        mPaint.color = Color.WHITE
////        canvas.drawRoundRect(RectF((config.currentPosition * indicatorWidth).toFloat(), 10F,
////            ((config.currentPosition + 1) * indicatorWidth + left).toFloat(), 15.dp.toFloat()), 10F, 10F, mPaint)
//
//
////        for (i in 0 until count) {
////            mPaint.color =
////                if (config.currentPosition == i) Color.parseColor("#05C29C") else Color.parseColor("#D7D7D7")
////            val path = Path()
////            path.fillType = Path.FillType.WINDING
////            path.moveTo(left + 5, 0f)
////            path.lineTo(left + indicatorWidth, 0f)
////            path.lineTo(left + indicatorWidth - 5, indicatorSpace.toFloat())
////            path.lineTo(left, indicatorSpace.toFloat())
////            path.lineTo(left + 5, 0f)
////            canvas.drawPath(path, mPaint)
////            canvas.drawLine(left, indicatorSpace.toFloat(), config.currentPosition * indicatorWidth + left, indicatorSpace.toFloat(), mPaint)
////            left += indicatorWidth + indicatorSpace.toFloat()
////        }
//    }
}